package errorx

const DefaultCode = 201

type CodeError interface {
	Code() int
	Error() string
	SetCode(int)
	SetMessage(string)
}

type Error struct {
	code    int
	message string
}

func NewError(code int, message string) CodeError {
	return &Error{code, message}
}

func NewDefaultError(message string) CodeError {
	return NewError(DefaultCode, message)
}

func (e *Error) Code() int {
	return e.code
}
func (e *Error) Error() string {
	return e.message
}

func (e *Error) SetCode(code int) {
	e.code = code
}
func (e *Error) SetMessage(message string) {
	e.message = message
}
